<template>

	<view class="wrap">
		<u-tabs :list="listx" :is-scroll="false" :current="current" @change="change" active-color='#F02B21'></u-tabs>
	
		<view class="" v-if="current==0">
			<view class="" v-if="lists.length>0">
				<view class="" v-for="(item,index) in lists" style="margin-top: 20rpx;">
					<view class="first">
						<view class="d_f j_c_s_b a_i_c" style="padding: 30rpx 22rpx 22rpx 22rpx">
							<view class="" style="font-size: 30rpx;color: #5F5E5E;">
							支付宝帐号:	{{item.alipay_account}}
							</view>
							<view class="" style="font-size: 28rpx; color: #F80808;">
								{{item.money}}
							</view>
						</view>
						<u-line color="#CECACA"  />
						<view class="d_f j_c_s_b a_i_c" style="padding: 10rpx 22rpx">
							<view class="" style="font-size: 26rpx;color: #5F5E5E;">
							申请提现时间
							</view>
							<view class="" style="font-size: 28rpx; color: #5F5E5E;">
								{{item.createtime}}
							</view>
						</view>
						<view class="d_f j_c_s_b a_i_c" style="padding: 10rpx 22rpx">
							<view class="" style="font-size: 26rpx;color: #5F5E5E;">
							提现金额
							</view>
							<view class="" style="font-size: 28rpx; color: #5F5E5E;">
								{{item.money}}
							</view>
						</view>
						<view class="d_f j_c_s_b a_i_c" style="padding: 10rpx 22rpx">
							<view class="" style="font-size: 26rpx;color: #5F5E5E;">
							到账时间
							</view>
							<view class="" style="font-size: 28rpx; color: #5F5E5E;">
								{{item.success_time}}
							</view>
						</view>
						<view class="d_f j_c_s_b a_i_c" style="padding: 10rpx 22rpx">
							<view class="" style="font-size: 26rpx;color: #5F5E5E;">
							交易流水号
							</view>
							<view class="" style="font-size: 28rpx; color: #5F5E5E;">
								{{item.out_order_no}}
							</view>
						</view>
						<view class="d_f j_c_s_b a_i_c" style="padding: 10rpx 22rpx">
							<view class="" style="font-size: 26rpx;color: #5F5E5E;">
							提现状态
							</view>
							<view class="" style="font-size: 28rpx; color: #F11414;" v-if="item.status=='提现失败'">
								{{item.status}}
							</view>
							<view class="" style="font-size: 28rpx; color: #73C82E;" v-if="item.status=='已到账'">
								{{item.status}}
							</view>
							<view class="" style="font-size: 28rpx; color: #2E89C8;" v-if="item.status=='提现中'">
								{{item.status}}
							</view>
							<view class="" style="font-size: 28rpx; color: red;" v-if="item.status=='申请提现'">
								{{item.status}}
							</view>
							
						</view>
						<view class="d_f j_c_s_b a_i_c" style="padding: 10rpx 22rpx" v-if="item.status==3">
							<view class="" style="font-size: 26rpx;color: #5F5E5E;">
							失败原因
							</view>
							<view class="" style="font-size: 28rpx; color: #5F5E5E;">
								{{item.fail_msg}}
							</view>
						</view>
						
						
					</view>
				</view>
				<u-loadmore :status="status" v-if="flags" />
			</view>
			<view class="d_f a_i_c j_c_c f_d_c " v-else>
				<image src="https://web.78keji.cn/images/ysh/ntx.png" mode="widthFix" style="width: 304rpx;margin-top: 390rpx;"></image>
				<view class="" style="font-size: 29rpx;color: #E3DFDF;">
					-暂无领取记录-
				</view>
			</view>
			
		</view>
		<view class="" v-else style="margin-top: 20rpx;">
			<view class="top d_f j_c_c a_i_c">
				<view class="">
					<view class="yue">
						可用余额
					</view>
					<view class="money">
						{{money}}
					</view>
				</view>
			</view>
			<view class="" v-for="(item,index) in list">
				 <view class="boss d_f j_c_s_b a_i_c">
				 	<view class="">
				 		<view class="" style="color: #454444; font-size: 18rpx;">
				 			{{item.date}} <text style="margin-left: 4rpx;">结算佣金</text>
				 		</view>
				 		<view class="time">
				 			{{item.createtime}}
				 		</view>
				 	</view>
					<view class="" style="font-size: 21rpx;color: #FF0404;">
						+{{item.price}}
					</view>
				 </view>
			</view>
			<u-loadmore :status="status" v-if="flag" />
		</view>
		
	</view>

</template>

<script>

	import moment from '../../utils/moment.js'
	import md5 from '../../utils/md5.js'
	export default {
		data() {
			return {
				status: 'loadmore',
								list: [],
								page: 1,
								page1:1,
								flags:false,
								money:"",
								flag:false,
								total:'',
								totals:'',
								lists:[],
								listx: [{
									name: '提现记录'
								}, {
									name: '余额明细'
								}, ],
								current: 0,
			}
		},
		
		components: {

		},
	onReachBottom() {
		console.log(111)
		if(this.current==0){
			if(this.totals>this.page1*10){
				this.flags=true
				this.page1+=1
				this.getdatas()
			}else{
				this.flags=false
			}
		}else{
			if(this.total>this.page*10){
				this.flag=true
				this.page+=1
				this.getdata()
			}else{
				this.flag=false
			}
		}
	
	
			},
		methods: {
			change(index) {
				this.current = index;
				
			},
	get(url) {
	  const parts = url.split(' ');
	  if (parts.length > 1) {
	    return parts[0]; // 
	  }
	  return ''; // 
	},
	getdatas(){
		uni.request({
			url: 'https://tcapi.sx2b2c.com/api/client_api/withdrawDepositRecordList', // 你的API地址
			method: 'POST',
		data:{
			page:this.page1,
			page_size:10
		},
			header: {
				'content-type': 'application/x-www-form-urlencoded', // 默认值
				token: uni.getStorageSync('token'),
			},
		
			success: (res) => {
				console.log('POST请求成功', res.data.data);
			
				this.totals=res.data.total
				// this.list=res.data.data.list
				for(var i in res.data.data){
					res.data.data[i].createtime = moment(res.data.data[i].createtime * 1000).format(
						"YYYY-MM-DD HH:mm:ss")
						if(res.data.data[i].success_time!=0){
							res.data.data[i].success_time = moment(res.data.data[i].success_time * 1000).format(
								"YYYY-MM-DD HH:mm:ss")
						}else{
							res.data.data[i].success_time='无'
						}
					if(res.data.data[i].status==0){
					res.data.data[i].status='申请提现'
					}else if(res.data.data[i].status==1){
							res.data.data[i].status='提现中'
					}else if(res.data.data[i].status==2){
							res.data.data[i].status='已到账'
					}else{
						res.data.data[i].status='提现失败'

					}
						
				
				}
			res.data.data.forEach((item) => {
			       this.lists.push(item);
			     });
			
		
			},
			fail: (err) => {
				console.error('POST请求失败', err);
			}
		});
	},
			getdata(){
				uni.request({
					url: 'https://tcapi.sx2b2c.com/api/client_api/incomeList', // 你的API地址
					method: 'POST',
				data:{
					page:this.page,
					page_size:10
				},
					header: {
						'content-type': 'application/x-www-form-urlencoded', // 默认值
						token: uni.getStorageSync('token'),
					},
				
					success: (res) => {
						console.log('POST请求成功', res.data.data);
						this.money=res.data.data.total_money
						this.total=res.data.total
						// this.list=res.data.data.list
						for(var i in res.data.data.list){
							res.data.data.list[i].createtime = moment(res.data.data.list[i].createtime * 1000).format(
								"YYYY-MM-DD HH:mm:ss")
								res.data.data.list[i].date=this.get(res.data.data.list[i].createtime)
								
						
						}
					res.data.data.list.forEach((item) => {
					       this.list.push(item);
					     });
					
				
					},
					fail: (err) => {
						console.error('POST请求失败', err);
					}
				});
			},


		},
		onLoad(option) {
this.getdatas()
	this.getdata()

		},
		watch: {

		},
		computed: {

		}
	}
</script>

<style scoped lang='scss'>
	.first{
		width: 720rpx;
		height: 389rpx;
		background: #FFFFFF;
		border-radius: 24rpx;
		
		margin: 0 auto;
	}
.wrap{
	background-color: #F5F5F5;
	position: relative;
	min-height: 100vh;
	padding-top: 20rpx;
	padding-bottom: 20rpx;
}
.top{
	width: 720rpx;
	height: 164rpx;
	background: #FFFFFF;
	border-radius: 24rpx;
	margin: 0 auto;
}
.yue{
	font-size: 25rpx;
	color: #605D5D;
}
.money{


	font-weight: bold;
	font-size: 45rpx;
	color: #000000;
	padding-top: 21rpx;
}
.boss{
	width: 720rpx;
	height: 126rpx;
	background: #FFFFFF;
	border-radius: 24rpx;
	margin: 0 auto;
	margin-top: 22rpx;
	padding: 42rpx 38rpx;
}
.time{



	font-size: 18rpx;
	color: #C2BCBC;
	margin-top: 20rpx;
}
</style>